﻿<Window x:Class="SettingsWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:NamaAlert="clr-namespace:co9320"
    ShowInTaskbar="False"
    
    Title="設定" Width="400" SizeToContent="Height" WindowStartupLocation="CenterOwner" Icon="/NamaAlert;component/MainWindow.ico" ResizeMode="NoResize">
    
    <Window.BindingGroup>
        <BindingGroup />
    </Window.BindingGroup>
    
    <Window.CommandBindings>
        <CommandBinding Command="{x:Static NamaAlert:SettingsWindow.SendMailCommand}" Executed="SendMailCommandBinding_Executed" CanExecute="SendMailCommandBinding_CanExecute" />
        <CommandBinding Command="{x:Static NamaAlert:SettingsWindow.PlaySoundCommand}" Executed="PlaySoundCommandBinding_Executed" CanExecute="PlaySoundCommandBinding_CanExecute" />
        
    </Window.CommandBindings>

    <Window.DataContext>
        <NamaAlert:UserSettings />
    </Window.DataContext>
    
    <Window.Resources>
        <NamaAlert:IntegerToStringConverter x:Key="IntegerToStringConverter" />
    </Window.Resources>

    <Grid Margin="8">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="33" />
        </Grid.RowDefinitions>
        <GroupBox Header="通知方法" Margin="5" Padding="5" >
            <StackPanel>
                <CheckBox Margin="5" IsChecked="{Binding Path=AlertWindowEnabled}">通知ウィンドウ</CheckBox>
                <CheckBox Margin="5" IsChecked="{Binding Path=BalloonEnabled}">バルーン表示</CheckBox>
                <CheckBox Margin="5" IsChecked="{Binding Path=WebOpeningEnabled}">生放送のページへ移動</CheckBox>
                <Expander Header="Webブラウザ設定（オプション・アプリ共通）" Margin="10 0 0 0" IsExpanded="False" >
                    <Grid Margin="0 5 0 5" >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition Width="70" />
                        </Grid.ColumnDefinitions>
                        <TextBox Margin="5 0" Text="{Binding Path=WebBrowserPath}" />
                        <StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right">
                            <Button Content="参照" Width="70" Click="SelectBrowserPathButton_Click" />
                        </StackPanel>
                    </Grid>
                </Expander>

                <CheckBox Margin="5" IsChecked="{Binding Path=EmailEnabled}">メール送信</CheckBox>

                <Expander Header="メール設定" Margin="10 0 0 0" IsExpanded="False" >
                    <Grid Margin="0 0 0 5"  >
                        <Grid.RowDefinitions >
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="65" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>

                        <Label Content="E-mail:" VerticalAlignment="Center" />
                        <TextBox Grid.Column="1" Margin="3" Text="{Binding Path=Email}" Name="EmailTextBox" />

                        <Label Grid.Row="1" Content="SMTP鯖:" VerticalAlignment="Center" />
                        <TextBox Grid.Row="1" Grid.Column="1" Margin="3" Text="{Binding Path=SmtpServer}" Name="SmtpServerTextBox" />

                        <Label Grid.Row="2" Content="ポート:" VerticalAlignment="Center" />
                        <TextBox Grid.Row="2" Grid.Column="1" Width="50" Margin="3" HorizontalAlignment="Left"  Text="{Binding Path=Port, Converter={StaticResource IntegerToStringConverter}, UpdateSourceTrigger=PropertyChanged}" Name="PortTextBox" />
                        
                        <StackPanel Grid.Row="3" Grid.Column="1" HorizontalAlignment="Right" Margin="0 5 0 0" >
                            <Button Width="80" Command="{x:Static NamaAlert:SettingsWindow.SendMailCommand}">テスト送信</Button>    
                        </StackPanel>
                    </Grid>

                </Expander>
                

                <CheckBox Margin="5" IsChecked="{Binding Path=SoundEnabled}">サウンド再生（Waveファイル）</CheckBox>
                <Expander Header="サウンド設定" Margin="10 0 0 0" IsExpanded="False" >
                    <Grid Margin="0 5 0 5" >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition Width="150" />
                        </Grid.ColumnDefinitions>
                        <TextBox IsReadOnly="True" Margin="5 0" Text="{Binding Path=SoundFile}" Name="SoundFileTextBox" />

                        <StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right">
                            <Button Content="参照" Margin="5 0" Width="70" Click="SelectSoundFileButton_Click" />
                            <Button Content="再生" Width="70" Command="{x:Static NamaAlert:SettingsWindow.PlaySoundCommand}" />
                        </StackPanel>
                    </Grid>
                </Expander>
                
            </StackPanel>
        </GroupBox>
        <StackPanel Grid.Row="1" Orientation="Horizontal" Margin="0 5 0 0" HorizontalAlignment="Right">
            <Button Content="OK" Margin="5 0" Width="80" IsDefault="True" Click="OkButton_Click" />
            <Button Content="キャンセル" Width="80" IsCancel="True" Click="CancelButton_Click" />
        </StackPanel>

    </Grid>
    
</Window>
